/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-02-17
 * Time: 12:53
 */
class Solution16 {
    public int maxProfit(int[] prices) {
        int profit = 0 , n = prices.length , minPrice = Integer.MAX_VALUE;
        for(int i = 0 ; i < n ; i++){
            minPrice = Math.min(minPrice,prices[i]);
            profit = Math.max(prices[i]-minPrice,profit);
        }
        return profit;
    }
}
public class Test16 {
}
